﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class NamHocData
    {
        DataService m_NamHocData = new DataService();

        public DataTable LayDsNamHoc()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM NAMHOC");
            m_NamHocData.Load(cmd);
            return m_NamHocData;
        }


        public void LuuNamHoc(String TenNh)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemNamHoc");

            cmd.Parameters.Add("@TENNAMHOC", SqlDbType.NVarChar).Value = TenNh;

            m_NamHocData.LoadProc(cmd);
        }

        public void UpdateNamHoc(String MaNH, String TenNh)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatNamHoc");

            cmd.Parameters.Add("@MaNH", SqlDbType.NVarChar).Value = MaNH;
            cmd.Parameters.Add("@TenNH", SqlDbType.NVarChar).Value = TenNh;

            m_NamHocData.LoadProc(cmd);
        }

        public void DeleteNamHoc(String MaNH)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaNamHoc");
            cmd.Parameters.Add("@MaNH", SqlDbType.Int).Value = Convert.ToInt32(MaNH);

            m_NamHocData.LoadProc(cmd);
        }
    }
}
